import pygame
import random

pygame.init()
icon = pygame.image.load("./game.png")
pygame.display.set_icon(icon)

SIZE = [2000, 1400]
FILL = [0, 0, 0]

screen = pygame.display.set_mode(SIZE)
# screen = pygame.display.set_mode([0, 0], pygame.FULLSCREEN)

pygame.display.set_caption("Zzzzzzzzzzzzzzzzzzzzzzzzzzzz...")

clock = pygame.time.Clock()


def get_random_color():
    alph = "0123456789abcdf"
    color = "#"
    for i in range(6):
        color += random.choice(alph)
    return color


class Circle:
    def __init__(self, x, y, m):
        self.x = x
        self.y = y
        self.m = m
        self.g = 1
        self.vy = self.g * self.m
        self.counter = 0
        self.color = get_random_color()
        self.r = 5

    def update(self):
        self.vy += self.g
        self.y += self.vy
        if self.y >= screen.get_height() - 200:
            self.jump()
        if self.y <= 0 + 100:
            self.push()

    def draw(self):
        pygame.draw.circle(screen, self.color, [self.x, self.y], self.r)

    def jump(self):
        self.vy -= 5
        print(self.vy)

    def push(self):
        self.vy += 5

    def move(self):
        if self.counter == 0:
            self.x += random.randint(1, 5)
            self.counter = 1
        if self.counter == 1:
            self.x -= random.randint(1, 5)
            self.counter = 0

    def animate(self):
        self.update()
        self.move()
        self.draw()


# circles = set()

# for i in range(100):
#     circles.add(
#         Circle(
#             random.randint(0, screen.get_width()),
#             random.randint(0, screen.get_height()),
#             10,
#         )
#     )
c = Circle(
            random.randint(0, screen.get_width()),
            random.randint(0, screen.get_height()),
            10,
        )
done = False
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    screen.fill(FILL)
    # for circle in circles:
    #     circle.animate()
    c.animate()
    pygame.display.flip()

    clock.tick(60)


pygame.quit()
